import React, { Component ,lazy,Suspense} from 'react';
import {  Switch, Route, Redirect,} from "react-router-dom";
import Loading from '../component/Loading';
import MyTabbar from "../component/MyTabbar";

var Home=lazy(()=>import('../views/Index/Home'))
var Allgood=lazy(()=>import('../views/Index/Allgood'))
var Category=lazy(()=>import('../views/Index/MyCategory'))
var Shopcart=lazy(()=>import('../views/Index/Shopcart'))
var Mine=lazy(()=>import('../views/Index/Mine'))
var NotFount=lazy(()=>import('../component/NotFount'))
class Index extends Component {
    render() {
        return (
            <div className='index'>
              <Suspense fallback={<Loading/>}>
                    {/* 定义二级路由规则 */}
              <Switch>
                        <Route  path='/index/home' component={Home}></Route>
                        <Route  path='/index/category' component={Category}></Route>
                        <Route  path='/index/allgood' component={Allgood}></Route>
                        <Route  path='/index/cart' component={Shopcart}></Route>
                    <Route  path='/index/mine' component={Mine}></Route>
                   
                    <Redirect  from='/index' to='/index/home'></Redirect>
                    <Route path='*' component={NotFount}></Route>

                    </Switch>
                </Suspense> 
                <MyTabbar></MyTabbar>
            </div>
        );
    }
}

export default Index;